package com.baice;

import com.baice.config.WebServerFactory;
import org.apache.catalina.LifecycleException;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

import javax.servlet.ServletException;


@ComponentScan("com.baice")
public class MyRunBoot {

    public static void main(String[] args) throws ServletException, LifecycleException {


        // Load Spring web application configuration
        //通过注解的方式初始化Spring的上下文
        AnnotationConfigWebApplicationContext ac=new AnnotationConfigWebApplicationContext();

        //注册spring的配置类（替代传统项目中xml的configuration）
        ac.register(MyRunBoot.class);   //手动去注册一个bean
        ac.refresh();

        // 启动Tomcat
        WebServerFactory factory = ac.getBean(WebServerFactory.class);
        factory.run();


    }
}

//这位同学 分享的笔记写的不错，参考了一下他的文章  ~ ~ ~ ~
// https://blog.csdn.net/qq_39404258/article/details/108464255
